home *** CD-ROM | disk | FTP | other *** search
- package sun.misc;
-
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.InterruptedIOException;
- import java.net.URL;
- import java.nio.ByteBuffer;
- import java.security.CodeSigner;
- import java.security.cert.Certificate;
- import java.util.jar.Manifest;
- import sun.nio.ByteBuffered;
-
- public abstract class Resource {
- private InputStream cis;
-
- public abstract String getName();
-
- public abstract URL getURL();
-
- public abstract URL getCodeSourceURL();
-
- public abstract InputStream getInputStream() throws IOException;
-
- public abstract int getContentLength() throws IOException;
-
- private synchronized InputStream cachedInputStream() throws IOException {
- if (this.cis == null) {
- this.cis = this.getInputStream();
- }
-
- return this.cis;
- }
-
- public byte[] getBytes() throws IOException {
- InputStream var2 = this.cachedInputStream();
- boolean var3 = Thread.interrupted();
-
- int var4;
- while(true) {
- try {
- var4 = this.getContentLength();
- break;
- } catch (InterruptedIOException var22) {
- Thread.interrupted();
- var3 = true;
- }
- }
-
- byte[] var1;
- try {
- int var5;
- if (var4 != -1) {
- for(var1 = new byte[var4]; var4 > 0; var4 -= var5) {
- var5 = 0;
-
- try {
- var5 = var2.read(var1, var1.length - var4, var4);
- } catch (InterruptedIOException var19) {
- Thread.interrupted();
- var3 = true;
- }
-
- if (var5 == -1) {
- throw new IOException("unexpected EOF");
- }
- }
- } else {
- var1 = new byte[1024];
- var5 = 0;
-
- while(true) {
- var4 = 0;
-
- try {
- var4 = var2.read(var1, var5, var1.length - var5);
- if (var4 == -1) {
- break;
- }
- } catch (InterruptedIOException var20) {
- Thread.interrupted();
- var3 = true;
- }
-
- var5 += var4;
- if (var5 >= var1.length) {
- byte[] var6 = new byte[var5 * 2];
- System.arraycopy(var1, 0, var6, 0, var5);
- var1 = var6;
- }
- }
-
- if (var5 != var1.length) {
- byte[] var25 = new byte[var5];
- System.arraycopy(var1, 0, var25, 0, var5);
- var1 = var25;
- }
- }
- } finally {
- try {
- var2.close();
- } catch (InterruptedIOException var17) {
- var3 = true;
- } catch (IOException var18) {
- }
-
- if (var3) {
- Thread.currentThread().interrupt();
- }
-
- }
-
- return var1;
- }
-
- public ByteBuffer getByteBuffer() throws IOException {
- InputStream var1 = this.cachedInputStream();
- return var1 instanceof ByteBuffered ? ((ByteBuffered)var1).getByteBuffer() : null;
- }
-
- public Manifest getManifest() throws IOException {
- return null;
- }
-
- public Certificate[] getCertificates() {
- return null;
- }
-
- public CodeSigner[] getCodeSigners() {
- return null;
- }
- }
-